#include<stdio.h>

void ShellSort(int* nums, int numsSize)
{
	int gap = numsSize;
	while (gap > 1)
	{
		gap /= 2;
		for (int i = 0; i < numsSize - gap; i++)
		{
			int end = i;
			int temp = nums[end + gap];
			while (end >= 0)
			{
				if (temp < nums[end])
				{
					nums[end + gap] = nums[end];
					end -= gap;
				}
				else
					break;
			}
			nums[end + gap] = temp;
		}
	}


}

void Print(int* nums, int numsSize)
{
	for (int i = 0; i < numsSize; i++)
		printf("%d ", nums[i]);
	printf("\n");
}

int main()
{
	int nums[] = { 9,8,7,6,5,4,3,2,1, };
	int len = sizeof(nums) / sizeof(int);
	ShellInset(nums, len);
	Print(nums, len);
	return 0;
}